package com.cloud.wyf.Mapper;

import com.cloud.wyf.Entity.LeaderScore;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface LeaderScoreMapper {

    @Insert("<script>insert into leaderscore(leaderid,middelid,year) values " +
            "<foreach collection = 'list' item='record' separator=',' >" +
            "(#{record.leaderid},#{record.middelid},#{record.year})" +
            "</foreach></script>")
    int addLeaderScoreMult(List<LeaderScore> list);

    @Select("select * from leaderscore where leaderid=#{leaderid} and middelid=#{middelid}")
    LeaderScore selectByLAndMId(@Param("leaderid") String leaderid,@Param("middelid")String middelid);

    @Select("select * from leaderscore where leaderid=#{leaderid}")
    List<LeaderScore> selectLeaderScoreByUid(String leaderid);

    @Update("<script>update leaderscore set item1=#{item1},item2=#{item2},item3=#{item3},item4=#{item4}," +
            "item5=#{item5},score=#{score},submittime=now()," +
            "status=1,flag=0,year=#{year}<if test=\"description != null and description != '' \">,description=#{description}</if> " +
            "where leaderid=#{leaderid} and middelid=#{middelid}</script>")
    int updateLeaderScore(LeaderScore leaderScore);

    @Update("update leaderscore set submittime=now(),flag=1 where leaderid=#{leaderid} and middelid=#{middelid}")
    int updateLeaderScoreQuit(@Param("leaderid") String leaderid,@Param("middelid")String middelid);

    @Select("select * from leaderscore where middelid=#{middelid}")
    List<LeaderScore> selectLeaderScoreByMiddelId(String middelid);//在middelid建立了索引
}
